// pages/person/message/userMobile/userMobile.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        userMobile: '13619560448',
        buttonmessage: '获取验证码',
        second: 5,
        disabled: false,
        loading: false,
        buttonmessage_1: '获取验证码',
        second_1: 5,
        disabled_1: true,
    },
    sendMessage: function () {
        this.timer()
        this.setData({
            disabled: true,
            buttonmessage: '',
            second: 4,
            disabled_1: false,
        })
    },
    timer: function () {
        let promise = new Promise((resolve, reject) => {
            let setTimer = setInterval(
                () => {
                    this.setData({
                        second: this.data.second - 1

                    })
                    if (this.data.second <= 0) {
                        this.setData({
                            second: 5,
                            buttonmessage: '获取验证码',
                            disabled: false
                        })
                        resolve(setTimer)
                    }
                }
                , 1000)
        })
        promise.then((setTimer) => {
            clearInterval(setTimer)
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },
    sendMessage_1: function () {
        this.timer_1()
        this.setData({
            disabled_1: true,
            buttonmessage_1: '',
            second_1: 4
        })
    },
    timer_1: function () {
        let promise = new Promise((resolve, reject) => {
            let setTimer = setInterval(
                () => {
                    this.setData({
                        second_1: this.data.second_1 - 1
                    })
                    if (this.data.second_1 <= 0) {
                        this.setData({
                            second_1: 5,
                            buttonmessage_1: '获取验证码',
                            disabled_1: false
                        })
                        resolve(setTimer)
                    }
                }
                , 1000)
        })
        promise.then((setTimer) => {
            clearInterval(setTimer)
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})